export default {
  data() {
    return {
      discoverInfo: [],
      // 热门搜索
      hotInfo: [],
      hotPage: 1,
      hotLastPage: 0,
      hotTap: false,
      keyWord: "",
      searchHistory: [],
      city:'',
      latitude:'',
      longitude:'',
      cityCode:''
    };
  },
  activated() {
    if ((this.$route.query.keyWord ?? "") !== "") {
      this.keyWord = this.$route.query.keyWord;
    }
    this.city = this.$route.query.city;
    this.latitude = this.$route.query.latitude;
    this.longitude = this.$route.query.longitude;
    this.cityCode = this.$route.query.cityCode;
    this.hotPage = 1;
  
    try {
      let History = localStorage.getItem("searchHistory") || [];
      this.searchHistory = JSON.parse(History);
    } catch (error) {
      console.log(error);
    }
  },
  methods: {
    goSearch() {
      if (this.keyWord) {
        this.$router.push(this.fun.getUrl("tourSearchPage", {}, { keyword: this.keyWord,city:this.city,latitude: this.latitude ,longitude:this.longitude,cityCode:this.cityCode}));
      }
    },
    tapKeyWord(key) {
      this.keyWord = key;
      this.$router.push(this.fun.getUrl("tourSearchPage", {}, { keyword: this.keyWord,city:this.city,latitude: this.latitude ,longitude:this.longitude,cityCode:this.cityCode}));
    },
    deleHistory() {
      localStorage.setItem("searchHistory", "");
      this.searchHistory = [];
    }
  }
};
